<template>
	<view class="container">
		<!-- 头部 -->
		<view class="header">
			<text class="header-title">学员培训平台</text>
			<view class="user-avatar">🔔</view>
		</view>

		<!-- 欢迎信息 -->


		<!-- 主要内容 -->
		<view class="main-content">
			<!-- 基础简介卡片 -->
			<view class="card" :style="{animationDelay: '0.1s'}">
				<view class="card-title">
					<view class="title-line"></view>
					<text>基础简介</text>
				</view>
				<view class="grid-container">
					<view class="quick-action" @click="openBasicInfo">
						<view class="icon">📝</view>
						<text>基础概况</text>
					</view>
					<view class="quick-action" @click="openTrainingSystem">
						<view class="icon">📊</view>
						<text>培训体系</text>
					</view>
					<view class="quick-action" @click="openSpecialCourse">
						<view class="icon">🌟</view>
						<text>特色课程</text>
					</view>
					<view class="quick-action" @click="openTrainingPackage">
						<view class="icon">📦</view>
						<text>培训套餐</text>
					</view>
					<view class="quick-action" @click="openTeachers">
						<view class="icon">👨‍🏫</view>
						<text>专业师资</text>
					</view>
					<view class="quick-action" @click="openContact">
						<view class="icon">📞</view>
						<text>联系我们</text>
					</view>
					<view class="quick-action" @click="openExhibition">
						<view class="icon">🏛️</view>
						<text>展厅预约</text>
					</view>
					<view class="quick-action" @click="goanswer">
						<view class="icon">📝</view>
						<text>测评</text>
					</view>
				</view>
			</view>

			<!-- 培训安排卡片 -->
			<view class="card" :style="{animationDelay: '0.2s'}">
				<view class="card-title">
					<view class="title-line"></view>
					<text>培训安排</text>
				</view>
				<view class="grid-container">
					<view class="quick-action" @click="openSignIn">
						<view class="icon">✅</view>
						<text>签到打卡</text>
					</view>
					<view class="quick-action" @click="openSchedule">
						<view class="icon">📅</view>
						<text>行程安排</text>
					</view>
					<view class="quick-action" @click="openFeedback">
						<view class="icon">📝</view>
						<text>培训反馈</text>
					</view>
					<view class="quick-action" @click="openMaterials">
						<view class="icon">📚</view>
						<text>学习资料</text>
					</view>
				</view>
			</view>

			<!-- 今日课程卡片 -->
		</view>

		<!-- 底部导航 -->
		<view class="tab-bar">
			<view class="tab-item" :class="{active: currentTab === 0}" @click="switchTab(0)">
				<van-icon name="home-o" size="20px" :color="currentTab === 0 ? '#4361ee' : '#6c757d'" />
				<text>首页</text>
			</view>
			<view class="tab-item" :class="{active: currentTab === 1}" @click="switchTab(1)">
				<van-icon name="user-o" size="20px" color="currentTab === 1 ? '#4361ee' : '#6c757d'" />
				<text>我的</text>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userinfo: null,
				student: null,
				currentTab: 0 // 当前选中的tab
			}
		},
		onShow() {
			// 每次页面显示时都重新获取缓存
			this.userinfo = uni.getStorageSync("userinfo");
			this.teacher = uni.getStorageSync("teacher");


			if (this.userinfo && this.teacher) {
				uni.switchTab({
					url: "/pages/index/index"
				})
				return
			}
		},
		methods: {
			iflogin() {
				if (!uni.getStorageSync("userinfo")) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return
				}
			},

			switchTab(index) {
				this.currentTab = index;
				if (index === 1) {

					this.iflogin()
					uni.navigateTo({
						url: '/pages/student/myhome' // 替换为你的"我的"页面路径
					});
				}
			},
			openBasicInfo() {
				uni.navigateTo({
					url: '/pages/student/indexitem/jichu'
				});
			},
			openTrainingSystem() {
				uni.navigateTo({
					url: '/pages/student/indexitem/peixun'
				});
			},
			openSpecialCourse() {
				uni.navigateTo({
					url: '/pages/student/indexitem/kecheng'
				});
			},
			openTrainingPackage() {
				uni.navigateTo({
					url: '/pages/student/indexitem/taocan'
				});
			},
			openTeachers() {
				uni.navigateTo({
					url: '/pages/student/indexitem/shizi'
				});
			},
			openContact() {
				uni.navigateTo({
					url: '/pages/student/indexitem/lianxi'
				});
			},
			openExhibition() {
				// uni.navigateTo({
				// 	url: '/pages/student/exhibition'
				// });
			},
			openSignIn() {
				this.iflogin()
				uni.navigateTo({
					url: '/pages/student/signIn'
				});
			},
			openSchedule() {
				this.iflogin()
				uni.navigateTo({
					url: '/pages/student/qingdaoProject'
				});
			},
			openFeedback() {
				this.iflogin()
				uni.navigateTo({
					url: '/pages/student/evaluate'
				});
			},
			openMaterials() {
				this.iflogin()
				uni.navigateTo({
					url: '/pages/student/content'
				});
			},
			goanswer() {
				this.iflogin()
				uni.navigateTo({
					url: '/pages/student/answer'
				});
			}
		}
	}
</script>

<style scoped>
	.container {
		font-family: 'Inter', 'PingFang SC', 'Microsoft YaHei', sans-serif;
		background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
		color: #212529;
		line-height: 1.6;
		-webkit-font-smoothing: antialiased;
		min-height: 100vh;
		padding-bottom: 60px;
	}

	.header {
		position: fixed;
		top: 0;
		width: 100%;
		background: rgba(255, 255, 255, 0.15);
		backdrop-filter: blur(10px);
		-webkit-backdrop-filter: blur(10px);
		padding: 170rpx 25rpx 25rpx 25rpx;
		z-index: 100;
		box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
		display: flex;
		justify-content: space-between;
		align-items: center;
		box-sizing: border-box;
	}

	.header-title {
		font-size: 1.5rem;
		font-weight: 600;
		color: #4361ee;
		letter-spacing: -0.5px;
	}

	.user-avatar {
		width: 36px;
		height: 36px;
		border-radius: 50%;
		background: linear-gradient(45deg, #4361ee, #3a0ca3);
		display: flex;
		align-items: center;
		justify-content: center;
		color: white;
		font-weight: bold;
	}



	.welcome-text {
		font-size: 1.2rem;
		font-weight: 600;
		color: #212529;
		display: block;
		margin-bottom: 8px;
	}

	.training-info {
		display: flex;
		justify-content: space-between;
		font-size: 0.9rem;
		color: #6c757d;
	}

	.sign-status {
		color: #4cc9f0;
		font-weight: 500;
	}

	.main-content {
		padding: 280rpx 16px 16px 16px;
	}

	.card {
		background: rgba(255, 255, 255, 0.15);
		backdrop-filter: blur(10px);
		-webkit-backdrop-filter: blur(10px);
		border-radius: 12px;
		padding: 16px;
		margin-bottom: 16px;
		box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
		border: 1px solid rgba(255, 255, 255, 0.2);
		transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
		opacity: 0;
		transform: translateY(20px);
		animation: fadeInUp 0.6s forwards;
	}

	@keyframes fadeInUp {
		to {
			opacity: 1;
			transform: translateY(0);
		}
	}

	.card-title {
		font-size: 1.2rem;
		margin-bottom: 12px;
		color: #4361ee;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.title-line {
		width: 4px;
		height: 16px;
		background: #4361ee;
		margin-right: 8px;
		border-radius: 2px;
	}

	.more-link {
		font-size: 0.8rem;
		color: #6c757d;
	}

	.grid-container {
		display: grid;
		grid-template-columns: repeat(3, 1fr);
		gap: 12px;
	}

	.quick-action {
		background: rgba(255, 255, 255, 0.3);
		border-radius: 12px;
		padding: 12px;
		text-align: center;
		transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
	}

	.quick-action text {
		font-size: 0.8rem;
		font-weight: 500;
		color: #212529;
		display: block;
		margin-top: 4px;
	}

	.quick-action .icon {
		width: 32px;
		height: 32px;
		margin: 0 auto;
		background: linear-gradient(45deg, #4361ee, #3a0ca3);
		border-radius: 50%;
		display: flex;
		align-items: center;
		justify-content: center;
		color: white;
		font-size: 16px;
	}

	.course-list {
		margin-top: 8px;
	}

	.course-item {
		display: flex;
		padding: 12px 0;
		border-bottom: 1px solid rgba(255, 255, 255, 0.2);
	}

	.course-item:last-child {
		border-bottom: none;
	}

	.course-time {
		font-weight: 500;
		color: #4361ee;
		margin-right: 12px;
		min-width: 50px;
	}

	.course-detail {
		flex: 1;
	}

	.course-name {
		font-weight: 500;
		display: block;
		margin-bottom: 4px;
	}

	.course-teacher {
		font-size: 0.8rem;
		color: #6c757d;
	}

	.tab-bar {
		position: fixed;
		bottom: 0;
		width: 100%;
		display: flex;
		background: rgba(255, 255, 255, 0.9);
		backdrop-filter: blur(10px);
		-webkit-backdrop-filter: blur(10px);
		box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
		z-index: 100;
	}

	.tab-item {
		flex: 1;
		text-align: center;
		padding: 8px 0;
		font-size: 0.9rem;
		color: #6c757d;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.tab-item.active {
		color: #4361ee;
		font-weight: 500;
	}

	/* 响应式设计 */
	@media (max-width: 768px) {
		.grid-container {
			grid-template-columns: repeat(3, 1fr);
		}
	}

	@media (max-width: 500px) {
		.header-title {
			font-size: 1.2rem;
		}

		.grid-container {
			grid-template-columns: repeat(2, 1fr);
		}

		.quick-action .van-icon {
			width: 28px;
			height: 28px;
		}

		.quick-action text {
			font-size: 0.7rem;
		}
	}
</style>